package com.bsj.power.pls.web;

import com.bsj.power.common.config.global.JsonResult;
import com.bsj.power.common.def.dto.PanelDTO;
import com.bsj.power.common.def.entity.Panel;
import com.bsj.power.pls.service.PanelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description 面板机绑卡机关系
 * @Author zhaoyang
 * @Date 2024/10/21 9:41
 */
@Slf4j
@RestController
@RequestMapping("/panel")
public class PanelController {

    @Autowired
    private PanelService panelService;

    /**
     * 新增
     *
     * @param panelDTO
     * @return
     */
    @PostMapping("/addPanel")
    public JsonResult addPanel(@Validated @RequestBody PanelDTO panelDTO) {
        return panelService.addPanel(panelDTO);
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @GetMapping("/delPanel")
    public JsonResult delPanel(@RequestParam Integer id) {
        return panelService.delPanel(id);
    }

    /**
     * 修改
     *
     * @param panelDTO
     * @return
     */
    @PostMapping("/updatePanel")
    public JsonResult updatePanel(@Validated @RequestBody PanelDTO panelDTO) {
        return panelService.updatePanel(panelDTO);
    }

    /**
     * 分页查询
     *
     * @param pageNumber 页码
     * @param pageSize   条数
     * @return
     */
    @RequestMapping("/listPanels")
    public JsonResult<List<Panel>> listPanels(Integer pageNumber, Integer pageSize) {
        return panelService.listPanels(pageNumber, pageSize);
    }



}
